package DataBase;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Vector;

public class AddNewTelephoneOrder {
	
	
	Vector<String> order;
	int status;

	
	public AddNewTelephoneOrder(Vector<String> order)
	{
		this.order=order;
	}
	
	
	
	public void saveNewOrder()
	{
		SQLConnection sc=new SQLConnection();
		
		try {
			
			PreparedStatement ps1 = sc.getConnection().prepareStatement("INSERT INTO telephoneOrder(telOrderId,date,time,name,numOfPersons,phoneNo,comments,status,restTable) values(?,?,?,?,?,?,?,'פתוח','לא שובץ');");	
			
			sc.getConnection().setAutoCommit(false);
			
			for(int i=1;i<8;i++)
			{
			ps1.setString(i,order.get(i-1));
			}
			
			ps1.executeUpdate();
			sc.getConnection().commit();
			ps1.close();
			status=1;
			sc.getConnection().close();
		}
		
		catch (SQLException e) {
			
			e.printStackTrace();
			status=0;
		}
		}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}
	
	
}
